package com.qire.manhua.activity;

import android.os.Bundle;

import com.qire.antsbinder.dal.exception.DataAccessException;
import com.qire.antscore.annotation.DalExceptionObserve;
import com.qire.antscore.annotation.RouteMapping;
import com.qire.antsrouter.inject.Autowired;
import com.qire.common.constant.Navigation;
import com.qire.common.constant.Url;
import com.qire.common.inject.EventControllerInjector;
import com.qire.common.inject.ViewModelInjector;
import com.qire.common.support.base.BaseActivity;
import com.qire.common.utils.ToastHelper;
import com.qire.common.widget.snackbar.Prompt;
import com.qire.manhua.R;
import com.qire.manhua.controller.PasswordChangeGuideController;
import com.qire.manhua.databinding.ActivityPasswordChangeGuideBinding;
import com.qire.manhua.model.viewModel.impl.PasswordChangeGuideViewModel;

import androidx.annotation.Nullable;

@RouteMapping(path = Navigation.Page.PasswordChangeGuidePage)
public class PasswordChangeGuideActivity extends BaseActivity<ActivityPasswordChangeGuideBinding> {

    @Autowired(injector = ViewModelInjector.class)
    PasswordChangeGuideViewModel viewModel;

    @Autowired(injector = EventControllerInjector.class)
    PasswordChangeGuideController controller;

    @Override
    public int layoutRid() {
        return R.layout.activity_password_change_guide;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        viewModel.onAddition(viewDataBinder());
        controller.onAddition(viewModel);

    }

    @Override
    public void finish() {
        if(viewModel.backPage()) {
            super.finish();
        }
    }

    @DalExceptionObserve(tags = {Url.ValidateOldPassword, Url.UpdatePassword})
    public void simpleExceptionHandle(DataAccessException e) {
        ToastHelper.showSnackBar(e.extraMsg, Prompt.ERROR);
    }

}
